package com.origin.onlinesys.web.controllers.modules.interviewsys;

import com.alibaba.fastjson.JSON;
import com.origin.onlinesys.domain.modules.interviewsys.EnrollType;
import com.origin.onlinesys.service.modules.interviewsys.impl.EnrollOriginServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created by Administrator on 2015/1/25 0025
 * 来源
 */
@Controller
@RequestMapping(value = "/management/enroll")
public class EnrollOrginController {
    @Autowired
    private EnrollOriginServiceImpl service;

    @RequestMapping(value = "/findAll")
    public @ResponseBody
    List<EnrollType> findAll(){
        EnrollType type = new EnrollType();
        type.setState("1");
        return service.selectByWhere(type);
    }

    @RequestMapping(value = "/findByWhere")
    public @ResponseBody
    List<EnrollType> findByWhere(@ModelAttribute EnrollType type){
        return service.selectByWhere(type);
    }

    @RequestMapping(value = "/findByStateY")
    public @ResponseBody
    List<EnrollType> findByStateY(){
        return service.selectByState("1");
    }

    @RequestMapping(value = "/findById")
    public @ResponseBody
    EnrollType findById(String id){
        return service.selectById(id);
    }

    @RequestMapping(value = "/add")
    public @ResponseBody
    EnrollType addEnr(@ModelAttribute EnrollType type){
        EnrollType bean = null;
        if(type.getId() != null){
            service.updateEnroll(type);
            bean = type;
        }else{
            bean = service.insertEnrollType(type);
        }
        return bean;
    }

    @RequestMapping(value = "/update")
    public void updateEnr(@ModelAttribute EnrollType type){
        service.update(type);
    }

    @RequestMapping(value = "/del")
    public @ResponseBody
    String deleteEnr(String id){
        service.deleteEnrollType(id);
        return "1";
    }
}
